<%- include ("../public/page_header.html")%>
<script src="/admin/js/jqPaginator.js"></script>

<div class="panel panel-default">
    <div class="panel-heading clearfix" style="display: flex;">
        
        <form action="/<%=adminPath%>/article" method="GET" class="fl" style="margin-right:20px;"> 
            <input type="text" name="keywords" class="search" placeholder="请输入搜索关键词" value="<%=keywords%>"/>

            <input type="submit" class="btn btn-primary" value="搜索">
        </form>
        <a href="/<%=adminPath%>/article/add" class="btn btn-primary">增加内容</a>
    </div>
    <div class="table-responsive">
        <table class="table table-bordered">
            <tr class="th">
                <th>名称</th>
                <th>分类</th>
                <th>图片</th>
                <!-- <th>跳转地址</th> -->
                <th class="text-center">排序</th>
                <th class="text-center">推荐</th>
                <th class="text-center">状态</th>
                <th class="text-center">操作</th>
            </tr>
            <tbody>
                <%for(var i=0;i<list.length;i++){%>
                <tr>
                    <td style="width: 363px;"><%=list[i].title%></td>
                    <td>
                        <%=list[i].cate[0].title%>
                    </td>
                    <td>
                        <%if(list[i].article_img){%>
                            <img src="/<%=list[i].article_img%>" width="80" />                      
                        <%}%>                     
                    </td>
                    <td class="text-center chSpanNum" data-id="<%=list[i]._id%>" data-model="Article" data-field="sort" data-num="<%=list[i].sort%>">
                        <%=list[i].sort%></span>
                    </td>
                    <td align="center">
                        <%if(list[i].is_best==1){%>
                        <span data-id="<%=list[i]._id%>" data-model="Article"
                            data-field="is_best">√</span>

                        <%}else{%>
                        <span  data-id="<%=list[i]._id%>" data-model="Article"
                            data-field="is_best">×</span>
                        <%}%>

                     </td>
                    <td align="center">
                        <%if(list[i].status==1){%>
                            <span class="label label-success chStatus" data-id="<%=list[i]._id%>" data-model="Article" data-field="status">显示</span>
                        <%}else{%>
                            <span class="label label-danger chStatus" data-id="<%=list[i]._id%>" data-model="Article" data-field="status">隐藏</span>
                        <%}%>

                     </td>

                     <td class="text-center"><a href="/<%=adminPath%>/article/edit?id=<%=list[i]._id%>">修改</a>　　
                        <a class="delete" href="/<%=adminPath%>/article/delete?id=<%=list[i]._id%>">删除</a></td>
                </tr>
                <%}%>
            </tbody>
        </table>

    </div>

</div>
 <!--分页-->
 <div class="pagination" id="pagination"></div>
<script>

    $('#pagination').jqPaginator({
        totalPages: <%=totalPages%>,
        visiblePages: 10,
        currentPage: <%=page%>,
        onPageChange: function (num, type) {
            if(type=='change'){
             location.href="/<%=adminPath%>/article?page="+num+"&keywords=<%=keywords%>";
            }
            $('#text').html('当前第' + num + '页');
        }
    });



</script>